package org.example.current.customer.rest;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.example.current.customer.client.CurrentProviderClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jie.luo
 * @description
 * @since 2020-06-16
 */
@RestController
public class CustomerRest {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private CurrentProviderClient currentProviderClient;


    @GetMapping("/hello")
    @SentinelResource("/hello")
    public String hello() {
        return "hello nacos customer";
    }

    @GetMapping("/test-feign")
    public String testOpenFeign(@RequestParam(name = "id") Integer id) {
        logger.debug("-----------------------test-feign--------------------------");
        String userName = currentProviderClient.getUserName(id);
        return userName;
    }

    @GetMapping("/test-feign-users")
    public String testOpenFeign() {
        logger.debug("-----------------------test-feign-users--------------------------");
        return currentProviderClient.getUsers();
    }

}
